package org.example.datastream;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author zss
 * @date 2021/8/11 13:21
 * @Email:451682479@qq.com 读
 */
public class DataStream2 {

    /**
     * DataOutputStream  可以以适当的方式把数据写入流中。 数据： 8种基础数据类型，字符串类型。
     *
     * @param args DataInputStream， 可以以适当的方式把数据读到程序中来
     */

    public static void main(String[] args) throws IOException {

        String path = "D:\\1My\\1BE-java\\io-stream-demo\\src\\main\\resources\\data.txt";

        //DataInputStream dataInputStream = new DataInputStream();

        DataInputStream inputStream = new DataInputStream(new FileInputStream(path));

        //写
//        outputStream.writeByte(100);
//        outputStream.writeShort(90);
//        outputStream.writeUTF("Hello world");

        byte b = inputStream.readByte();

        System.out.println(b);

        short i = inputStream.readShort();

        System.out.println(i);

        String s = inputStream.readUTF();

        System.out.println(s);

        inputStream.close();

        System.out.println("aaaaaaaaaaa");
    }
}
